﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Isha.Data;
using Isha.Infrastructure;
using Isha.Entities;
using Isha.Web.Mvc;

namespace Isha.Extensions.Folder
{
    [Command(typeof(Folder))]
    public class FolderCommand : IContentCommand
    {
        public void Execute()
        {
            if (IshaContext.Current.Request.FormCollection != null && (IshaContext.Current.Command == Commands.Create || IshaContext.Current.Command == Commands.Edit))
            {
                ContentItem contentItem = IshaContext.Current.ContentItem;

                contentItem.ContentXml = IshaContext.Current.Serializer(contentItem.Type, new Folder()
                {
                    BodyText = IshaContext.Current.Request.FormCollection["Folder_BodyText"]
                });

                IshaContext.Current.ContentItem = contentItem;
            }
        }
    }
}
